package meihua.stopcarapp.api;

import java.util.List;

import meihua.mylibrary.basebean.ResultModel;
import meihua.stopcarapp.bean.CouponEntity;
import meihua.stopcarapp.bean.EarningsEntity;
import meihua.stopcarapp.bean.ParkingEntity;
import meihua.stopcarapp.bean.SpendEntity;
import meihua.stopcarapp.bean.UserEntity;
import meihua.stopcarapp.bean.result.LadvanceResult;
import meihua.stopcarapp.bean.result.LockResult;
import meihua.stopcarapp.bean.result.MyWalletResult;
import meihua.stopcarapp.bean.result.OrderEcodeResult;
import meihua.stopcarapp.bean.result.UnLadvanceResult;
import meihua.stopcarapp.bean.result.UserResult;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import rx.Observable;

/**
 * Name: LGZ
 * Time: 2017/5/3.
 * Dec:
 */

public interface ApiService {

    //    @GET("testLogin.action")
    //    Observable<ResultModel<UserEntity>> login(
    //            @Query("username") String username,
    //            @Query("password") String password);
    //    @POST("testLogin.action")
    //    Observable<ResultModel<UserEntity>> login(
    //            @Field("username") String username,
    //            @Field("password") String password);


    //    $postDatas['longitude'] = '116.40355';
    //    $postDatas['latitude'] = '39.9000';

    @FormUrlEncoded
    @POST("Mapdata/mapshouy")
    Observable<ResultModel<List<ParkingEntity>>> getParkingList(
            @Field("longitude") String longitude,
            @Field("latitude") String latitude);

    @FormUrlEncoded
    @POST("Caropen/ladvance")
    Observable<ResultModel<LadvanceResult>> sendLadvance(
            @Field("phone") String phone,
            @Field("parking_list_num") String parking_list_num);

    @FormUrlEncoded
    @POST("Caropen/endadvance")
    Observable<ResultModel<UnLadvanceResult>> sendUnLadvance(
            @Field("adv_id") String adv_id,
            @Field("phone") String phone,
            @Field("parking_list_num") String parking_list_num);

    @FormUrlEncoded
    @POST("Caropen/lock")
    Observable<ResultModel<LockResult>> sendOpenLock(
            @Field("phone") String phone,
            @Field("parking_list_num") String parking_list_num);

    @FormUrlEncoded
    @POST("User/dosend")
    Observable<ResultModel<String>> sendCode(
            @Field("user_phone") String phone);

    @FormUrlEncoded
    @POST("User/Login")
    Observable<ResultModel<UserResult>> login(
            @Field("user_phone") String phone,
            @Field("user_code") String code);

    @FormUrlEncoded
    @POST("user/usetdatas")
    Observable<ResultModel<UserResult>> getUserById(
            @Field("user_id") String user_id,
            @Field("user_phone") String user_phone);

    @FormUrlEncoded
    @POST("User/Nickname")
    Observable<ResultModel<String>> getUserNickName(
            @Field("user_phone") String user_phone,
            @Field("user_id") String user_id,
            @Field("user_nickname") String user_nickname);

    @FormUrlEncoded
    @POST("User/Sex")
        //TODO : 服务器传的对象
    Observable<ResultModel<UserEntity>> getUserSex(
            @Field("user_phone") String user_phone,
            @Field("user_sex") String user_sex);


    @FormUrlEncoded
    @POST("User/changePhone")
    Observable<ResultModel<Integer>> getUserPhone(
            @Field("user_phone") String user_phone,
            @Field("user_id") String user_id);

    @FormUrlEncoded
    @POST("User/idcard")
    Observable<String> getUserIDCard(
            @Field("user_id") String user_id,
            @Field("user_phone") String user_phone,
            @Field("user_idcard") String user_idcard,
            @Field("user_name") String user_name
    );

    @FormUrlEncoded
    @POST("User/CarId")
    Observable<String> getUserCarId(
            @Field("user_phone") String user_phone,
            @Field("user_id") String user_id,
            @Field("user_carid") String user_carid
    );

    @FormUrlEncoded
    @POST("User/OutLogin")
    Observable<String> getUserQuit(
            @Field("user_phone") String user_phone,
            @Field("user_state") String user_id
    );

    @FormUrlEncoded
    @POST("Appcode/Mymoney")
    Observable<ResultModel<MyWalletResult>> getMyWallet(
            @Field("user_id") String user_id
    );

    @FormUrlEncoded
    @POST("Appcode/Couponlist")
    Observable<ResultModel<List<CouponEntity>>> getCouponList(
            @Field("user_id") String user_id
    );


    @FormUrlEncoded
    @POST("Appcode/Spendcode")
    Observable<ResultModel<List<SpendEntity>>> getSpendList(
            @Field("user_id") String user_id,
            @Field("num") String num
    );

    @FormUrlEncoded
    @POST("Appcode/Uearnings")
    Observable<ResultModel<List<EarningsEntity>>> getEarningList(
            @Field("user_id") String user_id,
            @Field("num") String num
    );

    @FormUrlEncoded
    @POST("ParkingShare/charging")
    Observable<ResultModel<String>> getCharging(
            @Field("order_num") String order_num,
            @Field("parking_list_num") String parking_list_num
    );

    @FormUrlEncoded
    @POST("ParkingShare/OrderEcode")
    Observable<ResultModel<OrderEcodeResult>> sendOrderEcode(
            @Field("order_num") String order_num,
            @Field("order_monry") String order_monry,
            @Field("coupon_id") String coupon_id,
            @Field("coupon_gid") String coupon_gid
    );

    @POST("/file")
    @Multipart
    Observable<ResultModel<String>> uploadFile(
            @Part("file\"; filename=\"avatar.png\"") RequestBody file);


}
